package it.accaemme.sgame;

import java.util.ArrayList;
import java.util.Random;

public class Players {
	Players(int max, ArrayList<Player> players){
		if(max<2)
			 this.maxplayers=2;
		 else
			 this.maxplayers = max;
		
		this.players = players;
	}
	
	 int getMaxPlayers(){
		return this.maxplayers;
	}
	
	 void decresePlayers(){
		this.maxplayers = this.maxplayers - 1;
	}
	
	 void increasePlayers(){
		this.maxplayers = this.maxplayers + 1; 
	}
	
	void addPlayer(int id, String nome, String sesso, String immagine){
		this.players.add( new Player(id, nome, sesso, immagine) );
	}
	
	
	void setCurPlayer(int cur){
		this.cur_player = cur;
	}
	
	
	int getCurPlayer(){
		return this.cur_player;
	}

	void setNextPlayer(){
		System.out.println("setNextPlater:" + maxplayers);
		int cur =  cur_player;
		if(( cur >= maxplayers) || (cur <= 0)){				
			cur = 1;
		} else {
			cur = cur+1;
		}
			
		this.cur_player = cur;
	}
	
	
	int getNextPlayer(){
		return this.cur_player;
	}
	
	
	public void setMaxPlayers(int i) {
			this.maxplayers = i;
	}
	 
	
	int getRandomPlayer(){
		Random rand = new Random();
		int m = maxplayers;
		if(maxplayers == 0) m=2; 
		return (rand.nextInt(m))+1;
	}
	
	int maxplayers, cur_player=1;
	ArrayList<Player> players;

}
